home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 September / PCWorld_2006-09_cd.bin / komercni software / zoner / zps8_cz.exe / {app} / HTMLPublish / compactPHP.zht / imgcmt1.php < prev    next >
PHP Script  |  2006-03-22  |  3KB  |  115 lines

  1. <?php
  2.  
  3. $entry = "<i>%who%</i>%details% %time%<bR>%text%<br><br>";
  4. $result = "";
  5.  
  6. include_once("fn.php");
  7.  
  8. function startElementE($parser, $name, $attrs) 
  9. {
  10.    if (strcmp($name,"COMMENT")==0)
  11.    {
  12.      global $entry;
  13.      global $result;
  14.  
  15.      $entrym1 =  " (<a href=\"mailto:%mail%\">e-mail</a>, <a href=\"%web%\">web</a>)";
  16.      $entrym2 =  " (<a href=\"mailto:%mail%\">e-mail</a>)";
  17.      $entrym3 =  " (<a href=\"%web%\">web</a>)";
  18.  
  19.      $res=str_replace("%who%",charDecode($attrs['PERSON']),$entry);
  20.      $res=str_replace("%text%",charDecode($attrs['TEXT']),$res);
  21.      $tm=$attrs['TIME'];
  22.      if (strcmp($tm,"")!=0)
  23.         $tm=date("d.m.Y H:i:s",$tm);
  24.      $res=str_replace("%time%",$tm,$res);
  25.  
  26.      $entrym="";
  27.      if (strcmp($attrs['MAIL'],"")!=0)
  28.      {
  29.     if (strcmp($attrs['WEB'],"")!=0 && strcmp($attrs['WEB'],"http://")!=0)
  30.        $entrym=$entrym1;
  31.         else
  32.        $entrym=$entrym2;
  33.      }
  34.      else
  35.     if (strcmp($attrs['WEB'],"")!=0 && strcmp($attrs['WEB'],"http://")!=0)
  36.        $entrym=$entrym3;
  37.      $resm=str_replace("%mail%",charDecode($attrs['MAIL']),$entrym);
  38.      $resm=str_replace("%web%",charDecode($attrs['WEB']),$resm);
  39.      
  40.      $res=str_replace("%details%",$resm,$res);
  41.  
  42.      $result=$result.$res;
  43.    }
  44. }
  45.  
  46. function endElementE($parser, $name) 
  47. {
  48. }
  49.  
  50. function vshowcomments($id)
  51. {
  52. $soubor="text/%num%.cmt";
  53. $soubor=str_replace("%num%",$id,$soubor);
  54. global $result;
  55.  
  56. if (file_exists($soubor)) 
  57. {
  58.   $xml_parser = xml_parser_create();
  59.   xml_set_element_handler($xml_parser, "startElementE", "endElementE");
  60.   if (!($fp = fopen($soubor, "r"))) {
  61.      die("could not open XML input");
  62.   }
  63.  
  64.   while ($xmldata = fread($fp, 4096)) {
  65.      if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
  66.          die(sprintf("XML error: %s at line %d",
  67.                      xml_error_string(xml_get_error_code($xml_parser)),
  68.                      xml_get_current_line_number($xml_parser)));
  69.      }
  70.   }
  71.   xml_parser_free($xml_parser);
  72. }
  73. $copy=$result;
  74. $result="";
  75. return $copy;
  76. }
  77.  
  78. $cmtcount=0;
  79. function startElementC($parser, $name, $attrs) 
  80. {
  81.   global $cmtcount;
  82.   if (strcmp($name,"COMMENTS")==0)
  83.   {
  84.      $cmtcount=(int)$attrs['COUNT'];
  85.   }
  86. }
  87.  
  88. function vgetcommentcount($id)
  89. {
  90. $soubor="text/%num%.cmt";
  91. $soubor=str_replace("%num%",$id,$soubor);
  92. global $cmtcount;
  93.  
  94. if (file_exists($soubor)) 
  95. {
  96.   $xml_parser = xml_parser_create();
  97.   xml_set_element_handler($xml_parser, "startElementC", "endElementE");
  98.   if (!($fp = fopen($soubor, "r"))) {
  99.      die("could not open XML input");
  100.   }
  101.  
  102.   while ($xmldata = fread($fp, 4096)) {
  103.      if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
  104.          die(sprintf("XML error: %s at line %d",
  105.                      xml_error_string(xml_get_error_code($xml_parser)),
  106.                      xml_get_current_line_number($xml_parser)));
  107.      }
  108.   }
  109.   xml_parser_free($xml_parser);  
  110. }
  111. return $cmtcount;
  112. }
  113.  
  114. ?>
  115.